winsafe\mf\com_interfaces/
imftopologynode.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::mf::vts::*;
6use crate::ole::privs::*;
7use crate::prelude::*;
8
9com_interface! { IMFTopologyNode: "83cf873a-f6da-4bc8-823f-bacfd55dc430";
10	/// [`IMFTopologyNode`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nn-mfidl-imftopologynode)
11	/// COM interface.
12	///
13	/// Automatically calls
14	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
15	/// when the object goes out of scope.
16	///
17	/// Usually created with
18	/// [`MFCreateTopologyNode`](crate::MFCreateTopologyNode) function.
19	///
20	/// # Examples
21	///
22	/// ```no_run
23	/// use winsafe::{self as w, prelude::*, co};
24	///
25	/// let topology_node = w::MFCreateTopologyNode(co::MF_TOPOLOGY::OUTPUT_NODE)?;
26	/// # w::HrResult::Ok(())
27	/// ```
28}
29
30impl mf_IMFAttributes for IMFTopologyNode {}
31impl mf_IMFTopologyNode for IMFTopologyNode {}
32
33/// This trait is enabled with the `mf` feature, and provides methods for
34/// [`IMFTopologyNode`](crate::IMFTopologyNode).
35///
36/// Prefer importing this trait through the prelude:
37///
38/// ```no_run
39/// use winsafe::prelude::*;
40/// ```
41pub trait mf_IMFTopologyNode: mf_IMFAttributes {
42	/// [`IMFTopologyNode::CloneFrom`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-clonefrom)
43	/// method.
44	fn CloneFrom(&self, node: &impl mf_IMFTopologyNode) -> HrResult<()> {
45		ok_to_hrresult(unsafe { (vt::<IMFTopologyNodeVT>(self).CloneFrom)(self.ptr(), node.ptr()) })
46	}
47
48	/// [`IMFTopologyNode::ConnectOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-connectoutput)
49	/// method.
50	fn ConnectOutput(
51		&self,
52		output_index: u32,
53		downstream_node: &impl mf_IMFTopologyNode,
54		input_index_on_downstream_node: u32,
55	) -> HrResult<()> {
56		ok_to_hrresult(unsafe {
57			(vt::<IMFTopologyNodeVT>(self).ConnectOutput)(
58				self.ptr(),
59				output_index,
60				downstream_node.ptr(),
61				input_index_on_downstream_node,
62			)
63		})
64	}
65
66	/// [`IMFTopologyNode::DisconnectOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-disconnectoutput)
67	/// method.
68	#[must_use]
69	fn DisconnectOutput(&self, output_index: u32) -> HrResult<()> {
70		ok_to_hrresult(unsafe {
71			(vt::<IMFTopologyNodeVT>(self).DisconnectOutput)(self.ptr(), output_index)
72		})
73	}
74
75	/// [`IMFTopologyNode::GetInput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getinput)
76	/// method.
77	///
78	/// Returns the node and the index of the output stream that is connected to
79	/// this node's input stream.
80	#[must_use]
81	fn GetInput(&self, input_index: u32) -> HrResult<(IMFTopologyNode, u32)> {
82		let mut queried = unsafe { IMFTopologyNode::null() };
83		let mut output_index_downstream_node = 0u32;
84		ok_to_hrresult(unsafe {
85			(vt::<IMFTopologyNodeVT>(self).GetInput)(
86				self.ptr(),
87				input_index,
88				queried.as_mut(),
89				&mut output_index_downstream_node,
90			)
91		})
92		.map(|_| (queried, output_index_downstream_node))
93	}
94
95	/// [`IMFTopologyNode::GetInputCount`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getinputcount)
96	/// method.
97	#[must_use]
98	fn GetInputCount(&self) -> HrResult<u32> {
99		let mut c = 0u32;
100		ok_to_hrresult(unsafe { (vt::<IMFTopologyNodeVT>(self).GetInputCount)(self.ptr(), &mut c) })
101			.map(|_| c)
102	}
103
104	/// [`IMFTopologyNode::GetNodeType`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getnodetype)
105	/// method.
106	#[must_use]
107	fn GetNodeType(&self) -> HrResult<co::MF_TOPOLOGY> {
108		let mut ty = co::MF_TOPOLOGY::default();
109		ok_to_hrresult(unsafe {
110			(vt::<IMFTopologyNodeVT>(self).GetNodeType)(self.ptr(), ty.as_mut())
111		})
112		.map(|_| ty)
113	}
114
115	/// [`IMFTopologyNode::GetObject`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getobject)
116	/// method.
117	#[must_use]
118	fn GetObject<T>(&self) -> HrResult<T>
119	where
120		T: ole_IUnknown,
121	{
122		let mut queried = unsafe { T::null() };
123		ok_to_hrresult(unsafe {
124			(vt::<IMFTopologyNodeVT>(self).GetObject)(self.ptr(), queried.as_mut())
125		})
126		.map(|_| queried)
127	}
128
129	/// [`IMFTopologyNode::GetOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getoutput)
130	/// method.
131	///
132	/// Returns the node and the index of the input stream that is connected to
133	/// this node's output stream.
134	#[must_use]
135	fn GetOutput(&self, output_index: u32) -> HrResult<(IMFTopologyNode, u32)> {
136		let mut queried = unsafe { IMFTopologyNode::null() };
137		let mut input_index_downstream_node = 0u32;
138		ok_to_hrresult(unsafe {
139			(vt::<IMFTopologyNodeVT>(self).GetOutput)(
140				self.ptr(),
141				output_index,
142				queried.as_mut(),
143				&mut input_index_downstream_node,
144			)
145		})
146		.map(|_| (queried, input_index_downstream_node))
147	}
148
149	/// [`IMFTopologyNode::GetOutputCount`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getoutputcount)
150	/// method.
151	#[must_use]
152	fn GetOutputCount(&self) -> HrResult<u32> {
153		let mut c = 0u32;
154		ok_to_hrresult(unsafe {
155			(vt::<IMFTopologyNodeVT>(self).GetOutputCount)(self.ptr(), &mut c)
156		})
157		.map(|_| c)
158	}
159
160	/// [`IMFTopologyNode::GetTopoNodeID`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-gettoponodeid)
161	/// method.
162	#[must_use]
163	fn GetTopoNodeID(&self) -> HrResult<u64> {
164		let mut id = 0u64;
165		ok_to_hrresult(unsafe {
166			(vt::<IMFTopologyNodeVT>(self).GetTopoNodeID)(self.ptr(), &mut id)
167		})
168		.map(|_| id)
169	}
170
171	/// [`IMFTopologyNode::SetObject`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-setobject)
172	/// method
173	fn SetObject(&self, object: &impl ole_IUnknown) -> HrResult<()> {
174		ok_to_hrresult(unsafe {
175			(vt::<IMFTopologyNodeVT>(self).SetObject)(self.ptr(), object.ptr())
176		})
177	}
178
179	/// [`IMFTopologyNode::SetTopoNodeID`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-settoponodeid)
180	/// method.
181	fn SetTopoNodeID(&self, topo_id: u64) -> HrResult<()> {
182		ok_to_hrresult(unsafe {
183			(vt::<IMFTopologyNodeVT>(self).SetTopoNodeID)(self.ptr(), topo_id)
184		})
185	}
186}